home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 16 code / CollaboDraw / base.window.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-24  |  7.7 KB  |  390 lines  |  [TEXT/MPS ]

  1. /*-------------------------------------------------------------------------------------
  2.  *
  3.  * Simple Sample PowerTalk Application Framework
  4.  *
  5.  * ©1991-1993 Apple Computer
  6.  *
  7.  -------------------------------------------------------------------------------------*/
  8. /*
  9.  * base.window.c -- base class for windows
  10.  *
  11.  * this is the base class for all of the window classes in the framework
  12.  * no windows of this class are actually instantiated, but all window
  13.  * classes are derived from this class
  14.  *
  15.  * change history:
  16.  *
  17.  * SJF        08/23/93        1.0f1        update to final headers, fix comments
  18.  * SJF        04/21/93        1.0b2        update to b2
  19.  * SJF        03/01/93        1.0b1        added digital signatures
  20.  * SJF        02/09/93        1.0b1        update to b1
  21.  * SJF        10/13/92        1.0d4        update to a11
  22.  * SJF        09/09/92        1.0d3        update to a9
  23.  * SJF        05/07/92        1.0d2        update to a6
  24.  * SJF        11/06/91        1.0d1        initial coding
  25.  *
  26.  */
  27.  
  28. #ifndef __TYPES__
  29. #include <Types.h>
  30. #endif
  31.  
  32. #ifndef __QUICKDRAW__
  33. #include <QuickDraw.h>
  34. #endif
  35.  
  36. #ifndef __WINDOWS__
  37. #include <Windows.h>
  38. #endif
  39.  
  40. #ifndef __MEMORY__
  41. #include <Memory.h>
  42. #endif
  43.  
  44. #ifndef __MENUS__
  45. #include <Menus.h>
  46. #endif
  47.  
  48. #include "const.h"
  49. #include "strconst.h"
  50. #include "mytypes.h"
  51. #include "globals.h"
  52. #include "utils.h"
  53. #include "windowstuff.h"
  54.  
  55. #include "base.window.h"
  56.  
  57.  
  58. /* instantiate a new base window */
  59.  
  60. WindowPtr BaseMakeWindow(Rect *wRect,StringPtr title,Boolean visible,short wdefProc,
  61.                         Boolean goAwayFlag)
  62. {
  63.     WInfoHndl infoHndl;
  64.     WInfoPtr infoPtr;
  65.     WindowPtr theWindow;
  66.     Str255 defaultTitle;
  67.     
  68.  
  69.     if (title==nil) {
  70.         GetResString(defaultTitle,kDefaultTitleID,kDefaultTitle);
  71.         title = defaultTitle;
  72.     }
  73.     
  74.     infoHndl = NewHandleChk(sizeof(WInfo));
  75.     if (MemError()!=noErr)
  76.         return nil;
  77.     
  78.     MoveHHi((Handle) infoHndl);
  79.     HLock((Handle) infoHndl);
  80.     infoPtr = *infoHndl;
  81.     
  82.     infoPtr->m_idle = BaseIdleWindow;
  83.     infoPtr->m_fixCursor = BaseFixCursorWindow;
  84.     infoPtr->m_activate = BaseActivateWindow;
  85.     infoPtr->m_deactivate = BaseDeactivateWindow;
  86.     infoPtr->m_update = BaseUpdateWindow;
  87.     infoPtr->m_key = BaseKeyWindow;
  88.     infoPtr->m_resize = BaseResizeWindow;
  89.     infoPtr->m_click = BaseClickWindow;
  90.     infoPtr->m_destroy = BaseDestroyWindow;
  91.     infoPtr->m_undo = BaseUndoWindow;
  92.     infoPtr->m_cut = BaseCutWindow;
  93.     infoPtr->m_copy = BaseCopyWindow;
  94.     infoPtr->m_paste = BasePasteWindow;
  95.     infoPtr->m_clear = BaseClearWindow;
  96.     infoPtr->m_print = BasePrintWindow;
  97.     infoPtr->m_pageSetup = BasePageSetupWindow;
  98.     infoPtr->m_save = BaseSaveWindow;
  99.     infoPtr->m_load = BaseLoadWindow;
  100.     infoPtr->m_event = BaseEventWindow;
  101.     infoPtr->m_ctrlHit = BaseHitControlWindow;
  102.     infoPtr->m_selectAll = BaseSelectAllWindow;
  103.     infoPtr->m_group = BaseGroupWindow;
  104.     infoPtr->m_unGroup = BaseUnGroupWindow;
  105.     
  106.     if (HasColorQD())
  107.         theWindow = NewCWindow(nil,wRect,title,visible,wdefProc,(WindowPtr)-1L,goAwayFlag,
  108.                                 (unsigned long)infoHndl);
  109.     else
  110.         theWindow = NewWindow(nil,wRect,title,visible,wdefProc,(WindowPtr)-1L,goAwayFlag,
  111.                                 (unsigned long)infoHndl);
  112.     
  113.     SetWindowKind(theWindow,kBaseWindow);
  114.     
  115.     pstrcpy(infoPtr->fileSpec.name,title);
  116.     infoPtr->refCount = gNextWindowToMake++;
  117.     infoPtr->window = theWindow;
  118.     infoPtr->saved = false;
  119.     infoPtr->changed = false;
  120.     infoPtr->fRefNum = 0;
  121.     infoPtr->resRefNum = 0;
  122.     infoPtr->topIndent = 0;
  123.     infoPtr->leftIndent = 0;
  124.     
  125.     infoPtr->printRecord = NewHandleChk(sizeof(TPrint));
  126.     if (MemError()!=noErr)
  127.         return nil;
  128.         
  129.     PrOpen();
  130.     PrintDefault(infoPtr->printRecord);
  131.     if (PrError()!=noErr)
  132.         DoError(PrError());
  133.     PrClose();
  134.     
  135.     return theWindow;
  136. }
  137.  
  138.  
  139. /* deallocate any memory associated with the base window class */
  140.  
  141. void *BaseDestroyWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  142. {    
  143.     #pragma unused (window,data)
  144.     
  145.     DisposHandleChk(infoPtr->printRecord);
  146.     
  147.     return nil;
  148. }
  149.  
  150.  
  151. /* handle null events for base window */
  152.  
  153. void *BaseIdleWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  154. {
  155.     #pragma unused (window,infoPtr,data)
  156.     
  157.     return nil;
  158. }
  159.  
  160.  
  161. /* handle mouse-moved events for base window */
  162.  
  163. void *BaseFixCursorWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  164. {
  165.     #pragma unused (window,infoPtr,data)
  166.     
  167.     return nil;
  168. }
  169.  
  170.  
  171. /* handle activate events for base window */
  172.  
  173. void *BaseActivateWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  174. {
  175.     #pragma unused (infoPtr,data)
  176.     
  177.     MyDrawGrowIcon(window);
  178.     return nil;
  179. }
  180.  
  181.  
  182. /* handle deactivate events for base window */
  183.  
  184. void *BaseDeactivateWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  185. {
  186.     #pragma unused (infoPtr,data)
  187.     
  188.     MyDrawGrowIcon(window);
  189.     SetDefaultMenus();
  190.     gMenusDirty = true;
  191.     return nil;
  192. }
  193.  
  194.  
  195. /* handle update events for base window */
  196.  
  197. void *BaseUpdateWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  198. {
  199.     #pragma unused (infoPtr,data)
  200.     
  201.     MyDrawGrowIcon(window);
  202.     return nil;
  203. }
  204.  
  205.  
  206. /* handle resize for base window */
  207.  
  208. void *BaseResizeWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  209. {    
  210.     #pragma unused (infoPtr,data)
  211.     Rect gbRect;
  212.     
  213.     gbRect = window->portRect;
  214.     gbRect.top = gbRect.bottom - kGrowBoxWidth;
  215.     gbRect.left = gbRect.right - kGrowBoxWidth;
  216.     EraseRect(&gbRect);
  217.  
  218.     return nil;
  219. }
  220.  
  221.  
  222. /* handle keypress for base window */
  223.  
  224. void *BaseKeyWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  225. {
  226.     #pragma unused (window,infoPtr,data)
  227.     
  228.     return nil;
  229. }
  230.  
  231.  
  232. /* handle mouse click in content for base window */
  233.  
  234. void *BaseClickWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  235. {
  236.     #pragma unused (window,data)
  237.     
  238.     infoPtr->changed = true;
  239.     return nil;
  240. }
  241.  
  242.  
  243. /* handle undo for base window */
  244.  
  245. void *BaseUndoWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  246. {
  247.     #pragma unused (window,infoPtr,data)
  248.     
  249.     return nil;
  250. }
  251.  
  252.  
  253. /* handle clipboard cut for base window */
  254.  
  255. void *BaseCutWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  256. {
  257.     #pragma unused (window,infoPtr,data)
  258.     
  259.     return nil;
  260. }
  261.  
  262.  
  263. /* handle clipboard copy for base window */
  264.  
  265. void *BaseCopyWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  266. {
  267.     #pragma unused (window,infoPtr,data)
  268.     
  269.     return nil;
  270. }
  271.  
  272.  
  273. /* handle clipboard paste for base window */
  274.  
  275. void *BasePasteWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  276. {
  277.     #pragma unused (window,infoPtr,data)
  278.     
  279.     return nil;
  280. }
  281.  
  282.  
  283. /* handle clipboard clear for base window */
  284.  
  285. void *BaseClearWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  286. {
  287.     #pragma unused (window,infoPtr,data)
  288.     
  289.     return nil;
  290. }
  291.  
  292.  
  293. /* handle select all for base window */
  294.  
  295. void *BaseSelectAllWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  296. {
  297.     #pragma unused (window,infoPtr,data)
  298.     
  299.     return nil;
  300. }
  301.  
  302.  
  303. /* handle group objects for base window */
  304.  
  305. void *BaseGroupWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  306. {
  307.     #pragma unused (window,infoPtr,data)
  308.     
  309.     return nil;
  310. }
  311.  
  312.  
  313. /* handle ungroup objects for base window */
  314.  
  315. void *BaseUnGroupWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  316. {
  317.     #pragma unused (window,infoPtr,data)
  318.     
  319.     return nil;
  320. }
  321.  
  322.  
  323. /* handle print for base window */
  324.  
  325. void *BasePrintWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  326. {
  327.     #pragma unused (window,infoPtr,data)
  328.     
  329.     return nil;
  330. }
  331.  
  332.  
  333. /* handle page setup for base window */
  334.  
  335. void *BasePageSetupWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  336. {
  337.     #pragma unused (window,data)
  338.     
  339.     infoPtr->changed = true;
  340.     
  341.     return nil;
  342. }
  343.  
  344.  
  345. /* handle save document for base window */
  346.  
  347. void *BaseSaveWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  348. {
  349.     #pragma unused (window,data)
  350.     
  351.     infoPtr->saved = true;
  352.     infoPtr->changed = false;
  353.  
  354.     return nil;
  355. }
  356.  
  357.  
  358. /* handle load document for base window */
  359.  
  360. void *BaseLoadWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  361. {
  362.     #pragma unused (window,data)
  363.     
  364.     infoPtr->saved = true;
  365.     infoPtr->changed = false;
  366.  
  367.     return nil;
  368. }
  369.  
  370.  
  371. /* handle generic event for base window */
  372.  
  373. void *BaseEventWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  374. {
  375.     #pragma unused (window,infoPtr,data)
  376.     
  377.     return nil;
  378. }
  379.  
  380.  
  381. /* handle mousedown in control for base window */
  382.  
  383. void *BaseHitControlWindow(WindowPtr window,WInfoPtr infoPtr,void *data)
  384. {
  385.     #pragma unused (window,infoPtr,data)
  386.     
  387.     return nil;
  388. }
  389.  
  390.